$ontext
===================================================================================
Name: VSPDReport.gms
Function: Creates the report templates
Developed by: Ramu Naidoo
Last modified: 01 December 2010
===================================================================================
$offtext

*===================================================================================
*Include some settings
*===================================================================================

$include vSPDpaths.inc
$include vSPDsettings.inc

*===================================================================================
*Create the reports
*===================================================================================

*Define output files
FILES
SystemResults                    / "%OutputPath%%runName%\%runName%_SystemResults.csv" /
OfferResults                     / "%OutputPath%%runName%\%runName%_OfferResults.csv" /
TraderResults                    / "%OutputPath%%runName%\%runName%_TraderResults.csv" /
BusResults_TradePeriod           / "%OutputPath%%runName%\%runName%_BusResults_TradePeriod.csv" /
NodeResults_TradePeriod          / "%OutputPath%%runName%\%runName%_NodeResults_TradePeriod.csv" /
OfferResults_TradePeriod         / "%OutputPath%%runName%\%runName%_OfferResults_TradePeriod.csv" /
ReserveResults_TradePeriod       / "%OutputPath%%runName%\%runName%_ReserveResults_TradePeriod.csv" /
BranchResults_TradePeriod        / "%OutputPath%%runName%\%runName%_BranchResults_TradePeriod.csv" /
BrCnstrResults_TradePeriod       / "%OutputPath%%runName%\%runName%_BrConstraintResults_TradePeriod.csv" /
MNodeCnstrResults_TradePeriod    / "%OutputPath%%runName%\%runName%_MNodeConstraintResults_TradePeriod.csv" /
;

*Set output file format
SystemResults.pc = 5;                    SystemResults.lw = 0;                   SystemResults.pw = 9999;
OfferResults.pc = 5;                     OfferResults.lw = 0;                    OfferResults.pw = 9999;
TraderResults.pc = 5;                    TraderResults.lw = 0;                   TraderResults.pw = 9999;
BusResults_TradePeriod.pc = 5;           BusResults_TradePeriod.lw = 0;          BusResults_TradePeriod.pw = 9999;
NodeResults_TradePeriod.pc = 5;          NodeResults_TradePeriod.lw = 0;         NodeResults_TradePeriod.pw = 9999;
OfferResults_TradePeriod.pc = 5;         OfferResults_TradePeriod.lw = 0;        OfferResults_TradePeriod.pw = 9999;
ReserveResults_TradePeriod.pc = 5;       ReserveResults_TradePeriod.lw = 0;      ReserveResults_TradePeriod.pw = 9999;
BranchResults_TradePeriod.pc = 5;        BranchResults_TradePeriod.lw = 0;       BranchResults_TradePeriod.pw = 9999;
BrCnstrResults_TradePeriod.pc = 5;       BrCnstrResults_TradePeriod.lw = 0;      BrCnstrResults_TradePeriod.pw = 9999;
MNodeCnstrResults_TradePeriod.pc = 5;    MNodeCnstrResults_TradePeriod.lw = 0;   MNodeCnstrResults_TradePeriod.pw = 9999;

*Write out summary reports
*System level
put SystemResults;
put 'Date', 'NumTradePeriodsStudied', 'ObjectiveFunctionValue ($)', 'SystemGen (MWh)', 'SystemLoad (MWh)', 'SystemLoss (MWh)', 'SystemViolation (MWh)', 'SystemFIR (MWh)'
    'SystemSIR (MWh)', 'SystemEnergyRevenue ($)', 'SystemReserveRevenue ($)', 'SystemLoadCost ($)', 'SystemLoadRevenue ($)', 'SystemSurplus ($)';

*Offer level
put OfferResults;
put 'Date', 'NumTradePeriodsStudied', 'Offer', 'Trader', 'Generation (MWh)', 'FIR (MWh)', 'SIR (MWh)', 'Energy Revenue ($)', 'FIR Revenue ($)', 'SIR Revenue ($)';

*Trader level
put TraderResults;
put 'Date', 'NumTradePeriodsStudied', 'Trader', 'Generation (MWh)', 'FIR (MWh)', 'SIR (MWh)', 'Energy Revenue ($)', 'FIR Revenue ($)', 'SIR Revenue ($)';

*TradePeriod reports
$if %TradePeriodReports%==0 $goto SkipTradePeriodReports

put BusResults_TradePeriod;
put 'DateTime', 'Bus', 'Generation (MW)', 'Load (MW)', 'Price ($/MWh)', 'Revenue ($)', 'Cost ($)', 'Deficit(MW)', 'Surplus(MW)';

put NodeResults_TradePeriod;
put 'DateTime', 'Node', 'Generation (MW)', 'Load (MW)', 'Price ($/MWh)', 'Revenue ($)', 'Cost ($)', 'Deficit(MW)', 'Surplus(MW)';

put OfferResults_TradePeriod;
put 'DateTime', 'Offer', 'Generation (MW)', 'FIR (MW)', 'SIR (MW)';

put ReserveResults_TradePeriod;
put 'DateTime', 'Island', 'FIR Reqd (MW)', 'SIR Reqd (MW)', 'FIR Price ($/MW)', 'SIR Price ($/MW)', 'FIR Violation (MW)', 'SIR Violation (MW)';

put BranchResults_TradePeriod;
put 'DateTime', 'Branch', 'FromBus', 'ToBus', 'Flow (MW) (From->To)', 'Capacity (MW)', 'DynamicLoss (MW)', 'FixedLoss (MW)', 'FromBusPrice ($/MWh)', 'ToBusPrice ($/MWh)', 'BranchPrice ($/MWh)', 'BranchRentals ($)';

put BrCnstrResults_TradePeriod;
put 'DateTime', 'BranchConstraint', 'LHS (MW)', 'Sense (-1:<=, 0:=, 1:>=)', 'RHS (MW)', 'Price ($/MWh)';

put MNodeCnstrResults_TradePeriod;
put 'DateTime', 'MNodeConstraint', 'LHS (MW)', 'Sense (-1:<=, 0:=, 1:>=)', 'RHS (MW)', 'Price ($/MWh)';

$label SkipTradePeriodReports
